package com.onpositive.wiki3.db.catmodel.matches;

import com.onpositive.wiki3.db.catmodel.Categories;
import com.onpositive.wiki3.db.catmodel.Category;
import com.onpositive.wiki3.db.catmodel.ICategoryMatcher;
import com.onpositive.wiki3.db.impl.CountingVocabalary;

public class DatePeriodCategorizationRemover implements ICategoryMatcher {

	protected CountingVocabalary vm = new CountingVocabalary();
	protected Categories sm = new Categories();
	protected int count;

	@Override
	public int accept(Category st) {

		for (Category categories : st.getChildCategories()) {
			if (categories == null) {
				continue;
			}
			String childTitle = categories.toString();
			if (childTitle.matches("(.)*_\\d\\d\\d\\d(-)+\\d\\d\\d\\d")) {
				String mc = childTitle.substring(0, childTitle.length() - 10);
				if (mc.endsWith(",")) {
					return -1;
				}
				if (mc.endsWith("_of")) {
					return -1;
				}
				int[] children2 = categories.getChildren();
				for (int z : children2) {
					sm.registerChild(categories.id(), z);
				}
				categories.replaceOn(st);
				count++;
			}
		}
		return -1;
	}

}
